
/**
 * usersettings.h
 * 
 * UserSettings holds all user settings saved in the PC
 * 
 * Copyright (c) 2008 Harunobu Oyama <nobukichi at gmail.com>
 * Licensed under GNU GPL version 3
 *
 */

#ifndef		USERSETTINGS_INCLUDED
#define		USERSETTINGS_INCLUDED

#include <QString>
#include <QSettings>

class UserSettings 
{
public:
	static UserSettings* get();

	//! make sure to store user settings in the PC
	void save();

	//! Twitter account related information
	QString	twitterUserName() const;
	QString	twitterPassword() const;
	bool saveTwitterPassword() const;
	void setTwitterUserName(QString usrName);
	void setTwitterPassword(QString passwd);
	void setSaveTwitterPassword(bool savePasswd);

	//! Group encryption related information
	QString gatewayUserName() const;
	QString encryptionKey() const;
	bool saveEncryptionKey() const;
	void setGatewayUserName(QString gatewayName);
	void setEncryptionKey(QString encKey);
	void setSaveEncryptionKey(bool saveKey);

	//! Http proxy related information
	bool useHttpProxy() const;
	QString httpProxy() const;
	int httpProxyPort() const;
	void setUseHttpProxy(bool use);
	void setHttpProxy(const QString& address);
	void setHttpProxyPort(int port);

	//! Proxy authentication related information
	QString	proxyUserName() const;
	QString	proxyPassword() const;
	bool saveProxyPassword() const;
	void setProxyUserName(QString usrName);
	void setProxyPassword(QString password);
	void setSaveProxyPassword(bool savePassword);

	//! Auto-update interval (min)
	int autoUpdateInterval() const;
	void setAutoUpdateInterval(int interval);

	//! Whether or not to save log file
	bool saveLog() const;
	void setSaveLog(bool save);

	//! Full-path of the log file folder
	QString logPath() const;
	void setLogPath(const QString& path);

private:
	UserSettings();

	//! helper functions
	QString encrypt(QString plain);
	QString decrypt(QString code);

	QSettings settings;

	QString	twitterPasswordCache;
	QString encryptionKeyCache;
	QString proxyPasswordCache;
};

#endif	//	USERSETTINGS_INCLUDED

